--- lpd/printjob.c.orig	Fri Jun  9 15:43:46 2006
+++ lpd/printjob.c	Fri Jun  9 15:43:57 2006
@@ -891,6 +891,23 @@
 {
 	int dfcopies, err, i;
 	char *cp, last[sizeof(line)];
+	/*
+	         * FreeBSD's cf files may put the 'N'(or 'J') after the 'f' line
+	         * open control file for Parsing the jobname first
+	*/
+	        if ((cfp = fopen(file, "r")) == NULL)
+	                return (OK);
+	
+	        while (getline(cfp)) {
+			if (line[0] == 'J' || line[0] == 'N') {
+			        if (line[1] != '\0') {
+			            strlcpy(jobname, line + 1, sizeof(jobname));
+			        } else
+			            strcpy(jobname, "(standard in)");
+			        break;
+			}
+		}
+		fclose(cfp);
 
 	/*
 	 * open control file
@@ -998,8 +1015,8 @@
 {
 	int i, amt;
 	struct stat stb;
-	char *av[15], *filtcmd;
-	char buf[SPL_BUFSIZ], opt_c[4], opt_h[4], opt_n[4];
+	char *av[17], *filtcmd;
+	char buf[BUFSIZ], opt_c[4], opt_h[4], opt_j[4], opt_n[4];
 	int copycnt, filtstat, narg, resp, sfd, sfres, sizerr, statrc;
 
 	/* Make sure the entire data file has arrived. */
@@ -1061,6 +1078,7 @@
 			narg = 0;
 			strcpy(opt_c, "-c");
 			strcpy(opt_h, "-h");
+			strcpy(opt_j, "-j");
 			strcpy(opt_n, "-n");
 			if (format == 'l')
 				av[++narg] = opt_c;
@@ -1071,6 +1089,8 @@
 			av[++narg] = logname;
 			av[++narg] = opt_h;
 			av[++narg] = origin_host;
+			av[++narg] = opt_j;
+			av[++narg] = jobname;
 			av[++narg] = pp->acct_file;
 			av[++narg] = NULL;
 		} else if (pp->filters[LPF_OUTPUT]) {
